﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Reminder.aspx.cs" Culture="en-GB" Inherits="Main_Master_Reminder" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="AjaxControl" %>
<%@ Register Src="~/User Controls/PageHeading.ascx" TagName="heading" TagPrefix="acc" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Reminder</title>
    <link href="../../Styles/accounts.css" rel="stylesheet" type="text/css" />
    <script language="javascript" type="text/javascript">
        function isNumberKey(control_id, evt) {
            var charCode = (evt.which) ? evt.which : event.keyCode
            if (charCode > 31 && (charCode < 48 || charCode > 57) && (charCode < 45 || charCode > 47))
                return false;

            if (charCode == 46) {
                var dotcount = document.getElementById(control_id).value.split('.').length - 1;
                if (dotcount >= 1) {
                    return false;
                }
            }
            return true;
        }
        function validate() {
            var flag = true;

            var ddlVouType = document.getElementById("ddlVoucherType");
            var txtRemName = document.getElementById("txtRemName").value;
            var txtRemDate = document.getElementById("txtRemDate").value;
            var ddlDebitLedger = document.getElementById("ddlDebitLedger");
            var ddlCreditLedger = document.getElementById("ddlCreditLedger");
            var txtAlertDays = document.getElementById("txtAlertDays").value;
            var txtActiveFrom = document.getElementById("txtActiveFrom").value;
            var ddlFreqRemind = document.getElementById("ddlFreqRemind");

            if (ddlVouType.value == "0") {
                alert("Please select Voucher Type !!");
                document.getElementById("ddlVoucherType").focus();
                flag = false;
            }
            else if (txtRemName == '') {
                alert("Please Enter Reminder Name !!");
                document.getElementById("txtRemName").focus();
                flag = false;
            }
            else if (txtRemDate == '' || txtRemDate == "__/__/____") {
                alert("Please Enter Reminder Date !!");
                document.getElementById("txtRemDate").focus();
                flag = false;
            }
            else if (ddlDebitLedger.value == "0") {
                alert("Please select Debit Ledger Name !!");
                document.getElementById("ddlDebitLedger").focus();
                flag = false;
            }
            else if (ddlCreditLedger.value == "0") {
                alert("Please select Credit Ledger Name !!");
                document.getElementById("ddlCreditLedger").focus();
                flag = false;
            }
            else if (txtAlertDays == "") {
                alert("Please Enter Alert Before Days !!");
                document.getElementById("txtAlertDays").focus();
                flag = false;
            }
            else if (txtActiveFrom == "") {
                alert("Please Enter Active From Date!!");
                document.getElementById("txtActiveFrom").focus();
                flag = false;
            }
            else if (ddlFreqRemind.value == "0") {
            alert("Please Select Frequency to remind !!");
            document.getElementById("ddlFreqRemind").focus();
            flag = false;
            }
            return flag;
        }
        function checkDebitCredit(id)
        {
            var flag=true;
            var ddlDebitLedger = document.getElementById("ddlDebitLedger");
            var ddlCreditLedger = document.getElementById("ddlCreditLedger");
            var ddlDebitValue=ddlDebitLedger.options[ddlDebitLedger.selectedIndex].value;
            var ddlCreditValue=ddlCreditLedger.options[ddlCreditLedger.selectedIndex].value;
            
            if(ddlDebitValue == ddlCreditValue && ddlDebitLedger.value != "0" && ddlCreditLedger.value != "0")
            {
            alert("Debit and Credit ledger can't be same !!");
            document.getElementById(id).focus();
            flag=false;
           }
           return flag;
     }
        
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="scriptmanager1" runat="server"></asp:ScriptManager>
    <acc:heading ID="pagehead" runat="server" HeadingText="Reminder" />
    <div style="width: 88%; margin-left: 7%; margin-right: 5%;">
      <div style="text-align:center; width:60%; margin-left:10%; margin-right:10%;">
       <asp:Label ID="lblMsg" runat="server" Font-Bold="true"></asp:Label></div>
        <table class="tablecontent" width="60%" cellpadding="2" style="margin-left: 10%; margin-right: 10%; margin-top:15px;">
            <tr>
                <td colspan="2">
                    &nbsp;
                </td>
            </tr>
            <tr>
                <td align="right" style="width:30%">
                    Voucher Type
                </td>
                <td  style="width:70%">
                    <asp:DropDownList ID="ddlVoucherType" runat="server" CssClass="dropdown"  Width="52%" AutoPostBack="true" OnSelectedIndexChanged="ddlVoucherType_SelectedIndexChanged">
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td align="right"  style="width:30%">
                    Reminder Name
                </td>
                <td  style="width:70%">
                    <asp:TextBox ID="txtRemName" runat="server" MaxLength="248" CssClass="input"  Width="50%"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td align="right"  style="width:30%">
                    Reminder Date
                </td>
                <td  style="width:70%"> 
                    <asp:TextBox ID="txtRemDate" runat="server" CssClass="input"  Width="50%"></asp:TextBox>
               
                    <asp:ImageButton ID="imgCalender" runat="server" ImageUrl="~/Images/calendar.gif" />
                    <AjaxControl:CalendarExtender id="calRemDate" runat="server" targetcontrolid="txtRemDate"
                        popupbuttonid="imgCalender" format="dd/MM/yyyy" enabled="True">
    </AjaxControl:CalendarExtender>
                    <AjaxControl:maskededitextender id="maskExt1" runat="server" masktype="Date" mask="99/99/9999"
                        targetcontrolid="txtRemDate" enabled="True">
                        </AjaxControl:maskededitextender>
                    <AjaxControl:maskededitvalidator id="maskValid1" runat="server" controlextender="maskExt1"
                        invalidvaluemessage="Invalid Date !" display="Dynamic" validationgroup="V" controltovalidate="txtRemDate"
                        errormessage="maskValid"></AjaxControl:maskededitvalidator>
                </td>
            </tr>
            <tr>
                <td align="right"  style="width:30%">
                    Debit Ledger
                </td>
                <td  style="width:70%">
                    <asp:DropDownList ID="ddlDebitLedger" runat="server" onblur="return checkDebitCredit(this.id);" onchange="return checkDebitCredit(this.id);" CssClass="dropdown" Width="52%">
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td align="right"  style="width:30%">
                    Credit Ledger
                </td>
                <td  style="width:70%">
                    <asp:DropDownList ID="ddlCreditLedger" runat="server" onblur="return checkDebitCredit(this.id);" onchange="return checkDebitCredit(this.id);" CssClass="dropdown"  Width="52%">
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td align="right"  style="width:30%">
                    Alert Before Days
                </td>
                <td  style="width:70%">
                    <asp:TextBox ID="txtAlertDays" runat="server" MaxLength="3" CssClass="inputnumber"  Width="50%" onkeydown="return isNumberKey(this.id, event);" ></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td align="right" style="vertical-align:top; width:30%">
                    Active Status
                </td>
                <td  style="width:70%">
                    <asp:RadioButtonList ID="rdbtnlstAlertStatus" runat="server" Width="50%">
                        <asp:ListItem Selected="True" Text="Active" Value="1"></asp:ListItem>
                        <asp:ListItem Selected="False" Text="Inactive" Value="0"></asp:ListItem>
                    </asp:RadioButtonList>
                </td>
            </tr>
            <tr>
                <td align="right"  style="width:30%">
                    Active from Date
                </td>
                <td  style="width:70%">
                    <asp:TextBox ID="txtActiveFrom" runat="server" CssClass="input" MaxLength="10"  Width="50%"></asp:TextBox>
              
                    <asp:ImageButton ID="imgCal2" runat="server" ImageUrl="~/Images/calendar.gif" />
                    <AjaxControl:CalendarExtender id="calActiveFrom" runat="server" targetcontrolid="txtActiveFrom"
                        popupbuttonid="imgCal2" format="dd/MM/yyyy" enabled="True">
                     </AjaxControl:CalendarExtender>
                    <AjaxControl:maskededitextender id="maskExt2" runat="server" masktype="Date" mask="99/99/9999"
                        targetcontrolid="txtActiveFrom" enabled="True">
                        </AjaxControl:maskededitextender>
                    <AjaxControl:maskededitvalidator id="maskValid2" runat="server" controlextender="maskExt2"
                        invalidvaluemessage="Invalid Date !" display="Dynamic" validationgroup="V" controltovalidate="txtActiveFrom"
                        errormessage="maskValid"></AjaxControl:maskededitvalidator>
                </td>
            </tr>
            <tr>
                <td align="right"  style="width:30%">
                    Frequency to Remind
                </td>
                <td  style="width:70%">
                    <asp:DropDownList ID="ddlFreqRemind" runat="server" CssClass="dropdown"  Width="52%" >
                        <asp:ListItem Selected="True" Text="-Select-" Value="0"></asp:ListItem>
                        <asp:ListItem Text="Daily" Value="1"></asp:ListItem>
                        <asp:ListItem Text="Weekly" Value="2"></asp:ListItem>
                        <asp:ListItem Text="Half Monthly" Value="3"></asp:ListItem>
                        <asp:ListItem Text="Monthly" Value="4"></asp:ListItem>
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td align="right"  style="width:30%; vertical-align:top;">
                    Remarks
                </td>
                <td  style="width:70%">
                    <asp:TextBox ID="txtRemarks" runat="server" MaxLength="248" CssClass="input" Width="51%" TextMode="MultiLine"></asp:TextBox>
                </td>
            </tr>
                 <tr>
                <td colspan="2"  style="width:100%">
                    &nbsp;
                </td>
            </tr>
        </table>
      <table width="60%" cellpadding="2" style="margin-left: 10%; margin-right: 10%; margin-top:15px;">
 <tr>
            <td align="right">
            <asp:Button ID="btnSubmit" runat="server" Text="Submit" ValidationGroup="V" OnClientClick="return validate();" CssClass="button" OnClick="btnSubmit_Click" />
            </td>
            <td align="left">
           &nbsp;&nbsp;<asp:Button ID="btnCancel" runat="server" Text="Cancel" CssClass="button" OnClick="btnCancel_Click" />
            </td>
            </tr>        
        </table>
    </div>
    </form>
</body>
</html>
